#include <iostream>
#include "BinaryTree.hpp"

using namespace std;

class Solution
{
public:
    TreeNode *invertTree(TreeNode *root)
    {
        if (root == nullptr)
        {
            return nullptr;
        }
        TreeNode *left = invertTree(root->left);
        TreeNode *right = invertTree(root->right);
        root->left = right;
        root->right = left;
        return root;
    }
};

int main()
{
    TreeNode *root = CreatTree("[4,2,7,1,3,6,9]", "null");
    PrintTreeByWide(root, "null", 3);
    Solution s;
    root = s.invertTree(root);
    PrintTreeByWide(root, "null", 3);
    return 0;
}